PART 5: LAN Interface Cards Definition The network interface card (NIC) is the piece of hardware that fits inside your computer to provide the physical connection to the network. Every computer attached to a LAN uses one sort of network interface card or another. In most cases, the card fits directly into the expansion bus of the computer. In some cases, the card will be part of a separate unit to which the computer attaches through a serial or parallel connection. The interface card takes data from your PC, puts it into the appropriate format and sends it over the cable to another LAN interface card. This card receives the data, puts it into a form the PC understands and sends it to the PC. Simple, right? Wrong. To get one byte of data from here to there hundreds of things must happen. Buffers must be checked. Requests must be acknowledged. Sessions must be established. Tokens must be sent. Collisions must be detected. The list can seem endless. Luckily, the work of the interface card can be broken down into eight tasks: host-card communications; buffering; packet formation; parallel-serial conversion; encoding/decoding; cable access; handshaking and transmission/reception. These are the steps taken to get data from the memory of one computer to the memory of another computer. Preparing for Transmission PC-NIC Communications. There are three ways to move data from the PC's memory to the network card and back again: DMA, I/O mapping and shared memory. Shared memory is just that. Part of host memory is shared by the network interface card's processor. This is a very fast method of transfer, since no buffering on the card is required. Both the card and the PC do their work on the data in the same place, so no transfer is necessary. DMA is short for Direct Memory Access. All Intel-based computers come with something called a DMA controller. It takes care of the transfer of data from an input/output device to the PC's main memory so the PC's main microprocessor, or CPU, does not have to. For DMA transfer, the controller or processor on the interface card sends a signal to the CPU indicating it needs DMA. The CPU then relinquishes control of the PC bus to the DMA controller. (The bus is the piece of the computer that connects other parts, e.g. memory and processor). Once the DMA controller has command of the bus, it begins to take the data from the card and place it directly in memory. It can do this because it has been informed by the CPU of the appropriate memory address at which to begin putting data in memory. After all the data is in memory, the DMA controller returns control of the bus to the CPU and tells it how much data has been put in memory. Of course, the whole process takes fractions of a second. There are two types of I/O transfers depending on the PC and peripheral. The two most important are memory-mapped I/O and program I/O. In a memory-mapped I/O transfer, the host CPU assigns some of its memory space to the I/O device, in this case the network interface card. So out of the possible 640K bytes available, some amount, say 12K bytes, are given to the network card. This memory is then treated as if it were main memory. No special instructions in the CPU are needed to get data from the card since it is like taking data from one part of main memory to another. With program I/O, the CPU is given a set of special instructions to handle the input/output functions. These instructions can be built into the chip or come with software. To send data, a request is sent from the network interface card to the CPU. The CPU then moves the data from the card over the bus to main memory. Shared memory is the fastest method of moving data between the network interface card and the PC, but it not often used for expense and execution reasons. The advantage of DMA is that it removes work from the CPU, so it can perform other functions while data transfer is taking place. The disadvantage is the CPU cannot access memory while the DMA controller is working. I/O mapping doesn't remove work from the CPU and it also takes up memory, but it can be faster than DMA. Different NICs use different types of NIC-PC communications. Yours will probably use DMA or program I/O. Experts disagree on which is better. If you really need to tell the difference, you'll have to experiment with your own applications. Buffering. Most NICs use a buffer. The buffer is a storage place that holds data as it is moving into and out of the NIC. The purpose of the buffer is simple: to make up for inherent delays in transmission. To do this, a buffer temporarily holds data, either for transmission onto the network cable or for transfer into the PC. While in the buffer, data may be acted on, "packetized" or "depacketized," or it may simply sit while the NIC handles other things. A buffer is needed because some parts of data transfer are slower than others. Data usually comes into the card faster than it can be converted from serial or parallel, depacketized, read and sent. This is true in both directions. Some NICs do not have buffers. Instead they use PC RAM. This can be less expensive, but usually slower. It also takes up precious memory. Packet formation. This is the most important job of the network and it is almost always done by the NIC. Packets are the units of transmission used on most LANs. Files and messages for transmission are broken up into packets as they are sent. At the other end the packets are put together to reform the original file or message. A packet has three sections: header, data and trailer. The header includes an alert to signal "packet on the way," the packet's source address, destination address and clock information to synchronize transmission. In some networks, headers also have preambles used for various purposes, like setting up parameters for transmission. They can also have a control field to direct the packet through the network, a byte count and a message type field. The data section is just that, the data being sent, for example, the numbers in a spreadsheet or words in a document. On some networks, the data section of a packet is as large as 12K bytes. On Ethernet, it is 4K bytes. Most networks fall between 1K and 4K bytes. The trailer has an error checking part called a cyclical redundancy check (CRC). It is a number which is the result of a mathematical calculation done on the packet by the sending NIC. When the packet arrives at its destination, the same mathematical calculation is repeated. If the result is the same, no errors occurred in transmission -- all the ones and zeros were in the right place. If the numbers don't match, an error occurred and the packet is sent again. The trailer, like the header, can hold other information. TRANSMISSION Parallel-serial conversion. Data comes from the PC in parallel form, eight bits at a time. It must travel over the cable in serial form, one bit at a time. And vice versa. Thus, the network interface card must perform the conversion between the two forms. Usually this is done by a controller on the card. Encoding/decoding. Once a packet is formed and changed from parallel to serial, it is ready for sending over the line. To do this it must be encoded; it must be converted into a series of electrical pulses that convey information. Most network interface cards use Manchester encoding. Serial data is divided into things called bit periods. Each of these periods (actual fractions of seconds) is divided in half. The two halves together represent a bit. From the first half to the second half of each bit period there is a change in the polarity of the signal, from positive to negative, or vice versa. There must be a change during each bit period because the change represents the data. A change from negative to positive represents a 1. A change from positive to negative represents a 0. Or vice versa depending on the network. Of course, it is these 1's and 0's that represent data. That's how digital data is actually sent using electrical impulses. Cable access. Before data can be sent, however, the network interface card must have access to the cable. Not all cards can send at once. If they do, their transmissions will collide and be lost. The various access methods used were discussed last month. Token Ring and Arcnet LANs use an electronic token to grant network access. Ethernet lets any workstation transmit at will and then look for collisions to see if it must transmit again. The entire protocol for the access method, all the circuitry and firmware (software written into hardware), resides on the network access card. This is its main job, getting data onto the cable in reliable form. Handshaking. After getting data from the PC, formatting it, encoding it and getting cable access, the network interface card has just one more task before it can send data: handshaking. In order to send data successfully, there must be a second NIC card waiting to receive it. To make sure, there is a short period of communication between two cards before data is sent. During this period, the parameters for the upcoming communication are decided upon through negotiation. During negotiation, the transmitting card sends the parameters it wants to use. The receiving card answers with its parameters. The card with the slower, smaller, less complicated parameters always wins. That's because more sophisticated cards can "lower" themselves while less sophisticated cards can't "raise" themselves. Negotiation sets the maximum packet size to be sent, how many packets before an answer, timer values, acknowledge time outs (how long to wait for an answer), buffer sizes, etc. Transmission/reception. Finally, everything is set. The only thing left is for the transceiver to put the data on the cable. The transceiver gives the data power to make it down the line. It actually puts the electrical signal out over the cable, making sure the data can get to the next card, the next repeater, amplifier or bridge. At the other end, a transceiver is waiting to accept the signal and begin the whole process in reverse, from modulated signal through decoding, serial- parallel conversion and depacketizing to PC-readable data. PICK A CARD Most people look only at performance when they choose a network interface card. Some will also consider the access method and topology used. This is fine when choosing the type of network interface card. Ethernet tends to be better for bursty networks. Its topology makes sense in scientific environments. Token Ring and Arcnet do better with constant traffic. Their topologies are better in offices. But there is more to choosing a network interface card than performance and access method. The most important consideration in buying a network interface is reliability. It doesn't matter how fast your network card is if it doesn't work, causes errors, loses packets, drops the line, etc. There is nothing more frustrating than having to isolate network hardware problems. Moreover, once found, replacing a network interface card means opening up a PC, setting dip switches and possibly reconfiguring software. Look for a network interface card that will work forever. This means talking to users and installers. Other considerations when buying a network interface card center on your application. Figure out what kind of traffic your network will be sending. Different topologies, different access methods and different cabling schemes will guide your choice of network interface card. So will the network operating system you plan on using. But we'll get to that hairy subject in next month's column. -- by Aaron Brenner